package map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class demo1 {
	public static void main(String[] args) {
		Map<String, String> map = new HashMap<>();

		map.put("b", "b1");
		map.put("c", "c1");
		map.put("d", "b1");

		Set<String> set = map.keySet();

		// 使用迭代器
		Iterator<String> it = set.iterator();
		while (it.hasNext()) {
			String key = it.next();
			String value = map.get(key);
			System.out.println(key + "=" + value);
		}
		System.out.println("=======2============");
		for (String a : set) {
			String value = map.get(a);
			System.out.println(a + "=" + value);
		}

		System.out.println("=======3============");
		Set<Map.Entry<String, String>> set1 = map.entrySet();
		// 使用迭代器
		Iterator<Map.Entry<String, String>> it1 = set1.iterator();
		while (it1.hasNext()) {
			Map.Entry<String, String> entry = it1.next();
			String aString = entry.getKey();
			String bString = entry.getValue();
			System.out.println(aString+"="+bString);
		}
	}
}
